print("You can print 'q' to quit.")

while True:
    try:
        first_str = input('\nPlease input first number:')
        if first_str == 'q':
            break
        first_val = int(first_str)

        second_str = input('\nPlease input second number:')
        if second_str == 'q':
            break
        second_val = int(second_str)
    except ValueError:
        print("The string which you input in not an interger!")
    else:
        sum = first_val + second_val
        print(f"The sum is {sum}.") 